package com.stadium.controller;

import java.util.List;
import java.util.UUID;

import com.stadium.common.BaseResponse;
import com.stadium.dto.SysAgreementDto;
import com.stadium.service.SysAgreementSV;
import com.stadium.vo.SysAgreementVo;
import com.stadium.vo.searchVo.SysAgreementSearchVo;
import io.micrometer.core.instrument.util.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 协议服务表
 *
 * @author wsl
 * @email
 * @date 2021-05-04 09:39:09
 */
@RestController
@RequestMapping("/api/sysagreement")
@Api(tags = "服务声明表")
public class SysAgreementCL{
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private SysAgreementSV sysAgreementSV;

    @ApiOperation(value = "保存或修改")
    @PostMapping(value = "/v1/save")
    public BaseResponse save(@Validated @RequestBody SysAgreementVo sysAgreementVo) {
        try {
            if (sysAgreementVo.getId() == null ||sysAgreementVo.getId() == ""){
                    sysAgreementSV.save(sysAgreementVo);
            }else{
                    sysAgreementSV.update(sysAgreementVo);
            }
            return BaseResponse.ok();

        } catch (Exception e) {
            e.printStackTrace();
            return BaseResponse.error();
        }
    }



    @ApiOperation(value = "获得用户协议", notes = "获得用户协议")
    @GetMapping(value = "/v1/get")
    public BaseResponse<SysAgreementDto> getAgreement() {
        try {
                SysAgreementDto queryData = sysAgreementSV.get();
            return BaseResponse.ok(queryData);
        } catch (Exception e) {
            logger.error("日志失败！", e);
            return BaseResponse.error();
        }
    }
}
